package lc20240602;

public class Graph {
    //顶点数量
    public int V;
   //邻接矩阵
    public int[][] adjMatrix;

    public Graph(int v){
        V=v;
        adjMatrix=new int[v][v];
    }

    public void addEdge(int v,int w){
        //对于无向图。
        adjMatrix[v][w]=1;
        adjMatrix[w][v]=1;
    }
    // 打印邻接矩阵
    public void printAdjMatrix() {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                System.out.print(adjMatrix[i][j] + " ");
            }
            System.out.println();
        }
    }
}
